package logmanager.view_properties;

import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JPanel;

//classe d'affichage d'un formulaire de chek box
public class CheckedForm extends JPanel{
	private static final long serialVersionUID = -6463637684813382780L;
	
	public static final int HORIZONTAL=0;
	public static final int VERTICAL=1;
	int labelsize=80;
	public CheckedForm(String title){
		setBorder(BorderFactory.createTitledBorder(
			BorderFactory.createEtchedBorder(),
			" " + title + " "	
		));
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	}
	public CheckedForm(String title, int labelsize){
		this(title);
		this.labelsize=labelsize;
	}
	public CheckedForm(String title, int labelsize, int align){
		this(title);
		this.labelsize=labelsize;
		switch (align) {
		case HORIZONTAL:
			setLayout(new FlowLayout(FlowLayout.LEFT));
			break;
		case VERTICAL:
			setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
			break;
		}
	}
	public void addField(String label){
		LabeledCheckBox ltf = new LabeledCheckBox(label, labelsize);
		add(ltf);
		ltf.setOpaque(false);
	}
	
	public JCheckBox getCheckBox(int i){
		return ((LabeledCheckBox)this.getComponent(i)).t;
	}
}
